<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<div id="formbody" class="formbody">    
<form action="<?php echo $modify_uri;?>" method="POST">  
    <div class="itab">
        <ul>
            <li><a href="#tab1">常规设置</a></li>
            <li><a href="#tab2">默认SEO</a></li> 
            <li><a href="#tab3">页面内容</a></li>
        </ul>
    </div>
    <div style="height: 10px;"></div>
    <div id="tab1" class="tabson"></div>    
    <div id="tab2" class="tabson"></div>
    <div id="tab3" class="tabson"></div> 
    <ul class="forminfo">
        <li><label>&nbsp;</label><input type="submit" class="btn" value="应用设置"/></li>
    </ul>
</form>
</div>

<!-- 模板 -->
<script id="t1" type="text/html">
<ul class="forminfo">            
    <li><label>网站名称</label><input name="site_name" value="<%=site_name%>" type="text" class="dfinput" /></li>
    <li>
        <label>网站LOGO</label>
        <span class="imgshow" id="site_log">
            <input name="site_logo" value="<%=site_logo%>" type="hidden" />
            <div class="infobox">
                <img src=""/>
                <a>×</a>
            </div>
        </span>
        <a class="file"><span>上传图片</span><input id="up_site_log" name="up_site_log" type="file" /></a>
    </li>
    <li>
        <label>页面缓存</label>
        <cite>
            <input id="page_cache_yes" name="page_cache" type="radio" value="1" <%=page_cache?'checked="checked"':''%>/>
            <label for="page_cache_yes">是</label>
            <input id="page_cache_no" name="page_cache" type="radio" value="0"  <%=page_cache?'':'checked="checked"'%>/>
            <label for="page_cache_no">否</label>
        </cite>
    </li>
    <li><label>缓存时间</label><input name="cache_time" value="<%=cache_time%>" style="width:160px" type="text" class="dfinput"/><i>单位：秒</i></li>
    <li>
        <label>QQ客服</label>
        <cite>
            <input id="kf_enable_yes" name="kf_enable" type="radio" value="1" <%=kf_enable?'checked="checked"':''%>/>
            <label for="kf_enable_yes">显示</label>
            <input id="kf_enable_no" name="kf_enable" type="radio" value="0" <%=kf_enable?'':'checked="checked"'%>/>
            <label for="kf_enable_no">不显示</label>
        </cite>
    </li>
    <?php if($is_super){?>
    <li>
        <label>banner效果</label> 
        <select name="banner_style" class="selectmenu">
        <option value="style1" <%=banner_style=='style1'?'selected="selected"':''%>>效果1</option>
        <option value="style2" <%=banner_style=='style2'?'selected="selected"':''%>>效果2</option>
        </select> 
    </li>
    <?php }?>
    <li><label>第三方脚本</label><textarea name="third_script" class="textinput"><%=third_script%></textarea></li>
</ul>
</script>
<script id="t2" type="text/html">
<ul class="forminfo">            
    <li><label>标题</label><input name="site_title" value="<%=site_title%>" style="width:480px" type="text" class="dfinput" /><i>title标签</i></li>
    <?php if($is_bilingual){?>
    <li><label>标题(英文版)</label><input name="en_site_title" value="<%=en_site_title%>" style="width:480px" type="text" class="dfinput" /><i>title标签</i></li>
    <?php }?>

    <li><label>关键词</label><input name="site_keywords" value="<%=site_keywords%>" style="width:480px" type="text" class="dfinput" /><i>对应keywords</i></li>
    <?php if($is_bilingual){?>
    <li><label>关键词(英文版)</label><input name="en_site_keywords" value="<%=en_site_keywords%>" style="width:480px" type="text" class="dfinput" /><i>对应keywords</i></li>
    <?php }?>

    <li><label>描述</label><textarea name="site_description" class="textinput"><%=site_description%></textarea><i>对应description</i></li>
    <?php if($is_bilingual){?>
    <li><label>描述(英文版)</label><textarea name="en_site_description" class="textinput"><%=en_site_description%></textarea><i>对应description</i></li>
    <?php }?>
    </ul> 
</script>
<script id="t3" type="text/html">
<ul class="forminfo">
    <li><label>首页介绍</label><textarea name="home_intro" class="textinput"><%=home_intro%></textarea></li>    
    <?php if($is_bilingual){?>
    <li><label>首页介绍<br/>(英文版)</label><textarea name="en_home_intro" class="textinput"><%=en_home_intro%></textarea></li>    
    <?php }?>
    
    <li><label>边栏联系</label><textarea name="side_contact" class="textinput"><%=side_contact%></textarea></li>
    <?php if($is_bilingual){?>
    <li><label>边栏联系<br/>(英文版)</label><textarea name="en_side_contact" class="textinput"><%=en_side_contact%></textarea></li>
    <?php }?>
    
    <li><label>页面底部</label><textarea name="site_footer" class="textinput"><%=site_footer%></textarea></li>
    <?php if($is_bilingual){?>
    <li><label>页面底部<br/>(英文版)</label><textarea name="en_site_footer" class="textinput"><%=en_site_footer%></textarea></li>
    <?php }?>    
</ul> 
</script>
<script src="js/template-helper.js" type="text/javascript"></script>
<script type="text/javascript"> 
function show(){
	$.getJSON(
	        '<?php echo $get_uri;?>',
	        {},
	        function(rs){
	             if(rs.err===0){
	            	  $('#tab1').html(template('t1', rs.data));
	            	  $('#tab2').html(template('t2', rs.data));
	            	  $('#tab3').html(template('t3', rs.data));
	            	  
	            	  $( ".selectmenu" ).selectmenu({width: 162});

	            	  $('.imgshow .infobox').hover(function(){
	            		  $(this).find('a').show();
		              },function(){
		            	  $(this).find('a').hide();
		              });
	            	  $('.imgshow a').on('click', function(){
		            	  $(this).parent().siblings('input').val('');
	            	      infoshow($(this).parent().parent());
	            	  });
	            	  $('.imgshow').each(function(){
	            		  infoshow($(this));
	            	  });
	              }else{
	                  layer.msg(rs.msg, {icon:2,time:2000});
	              }            
	        }
	);	
}
$("#formbody .itab ul").idTabs({
	start:window.location.hash?window.location.hash.substring(1).replace('t','tab'):'tab1',
	click:function(tab){
		window.location.hash = tab.substring(1).replace('tab','t');
		return true;
	}
});
function infoshow($el){
	var src = $el.find('input').val();
	if(src){
		$el.find('img').attr('src','<?php echo up_path();?>' + src);
		$el.find('.infobox').show();
	}else{
		$el.find('.infobox').hide();
	}
}
$("#formbody").on('change', '#up_site_log', function(){
	$.ajaxFileUpload({
	    url:'<?php echo site_url('ajax/upload_handle/image');?>',
	    fileElementId:'up_site_log',
	    dataType: 'json',
	    success: function(rs,status){
	        if(rs.err===0){
		        $('#site_log input').val(rs.data.save);
		        infoshow($('#site_log'));
	        }else{
	        	layer.msg(rs.msg, {icon:2,time:2000});
	        }
	    }
	});
});
$('form').on('submit', function(e) {
    e.preventDefault();
	var this_btn = $(this);
    if(!this_btn.attr('disabled')){
    	this_btn.attr('disabled',true);
    }else{
        return;
    }
    $(this).ajaxSubmit({
    	dataType:'json',
    	success:function(rs){
    		if(rs.err===0){
                layer.msg('应用成功！', {icon:1,time:2000}, function(){
                	this_btn.attr('disabled',false);
                });
            }else{
                layer.msg(rs.msg, {icon:2,time:2000}, function(){
                	this_btn.attr('disabled',false);
                });
            }
    		show();
		}
    });
});
show();
</script>
    